package com.mrd.gtimp.query.action;


import com.mrd.exception.QueryException;
import com.mrd.framework.ui.filter.Filter;
import com.mrd.gtimp.base.entity.User;
import com.mrd.gtimp.sup.entity.SupShipMentInfo;
import com.mrd.gtimp.sup.service.SupCustomerBiz;
import com.mrd.gtimp.sup.service.SupShipMentInfoBiz;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

import javax.annotation.Resource;

/**
 * <p> application name: gtimp <p> copyright: Copyright@2012 明睿达科技有限公司
 */

/**
 * @author luob
 */

@Controller
@RequestMapping("/query")
public class ShipMentInfoQueryAction {
    private static final long serialVersionUID = 1L;
    @Resource
    private SupShipMentInfoBiz supShipMentInfoBiz;

    @Resource
    private SupCustomerBiz supCustomerBiz;

    private SupShipMentInfo supShipMentInfo;

    private List<SupShipMentInfo> supShipMentInfos;

    private String jsonString;

    /**
     * public String show() {
     * try {
     * page = initPage(SupShipMentInfoBiz.findEntityCount(filters));
     * Order order = new Order();
     * order.add(sidx, sord);
     * SupShipMentInfos = SupShipMentInfoBiz
     * .findEntityByFilter(page.getCurrentPageStartNo(), page.getPageSize(), filters, order);
     * } catch (Exception e) {
     * e.printStackTrace();
     * }
     * return SUCCESS;
     * }
     **/

    /**
     * 默认访问入口
     */
    @RequestMapping("/shipMentInfoQuery-main")
    public String main() {
        return "/gtimp/query/shipMentInfoQueryList";
    }

    /**
     * 编辑信息
     */
    @RequestMapping("/shipMentInfoQuery-find")
    public String find() {
        if (null != supShipMentInfo) {
            if (StringUtils.isNotEmpty(supShipMentInfo.getID())) {
                try {

                    supShipMentInfo = supShipMentInfoBiz.findEntityById(supShipMentInfo.getID());
                } catch (QueryException e) {
                    e.printStackTrace();
                }
            }
        }
        //// TODO: 2016/8/15  json
        return null;
    }

    /**
     * 查询
     */
    @RequestMapping("/shipMentInfoQuery-findList")
    public String findList(User user, Filter filters) {
        // String comId = user.getCompany().getId();// get from user
        try {
            //// TODO: 2016/8/15  page
//        String supIds = supCustomerBiz.getSelfSupCompanyStr(user);
//        if (StringUtils.isNotEmpty(supIds)) {
//            filters.addRule(new SearchRule("owner.id", SearchRuleOption.in, supIds));
//                page = initPage(supShipMentInfoBiz.findEntityCount(filters));
//                Order order = new Order();
//                if (null != sidx && !"".equals(sidx)) {
//                    order.add(sidx, sord);
//                } else {
//                    order.add("owner.name", true);
//                }
//                supShipMentInfos = supShipMentInfoBiz.findEntityByFilter(page
//                        .getCurrentPageStartNo(), page.getPageSize(), filters, order);
//            }
//        } catch (QueryException e) {
        } catch (Exception e) {
            e.printStackTrace();
        }
        //// TODO: 2016/8/15  json
//        return "gridData";
        return null;


    }

    public void setSupShipMentInfoBiz(SupShipMentInfoBiz supShipMentInfoBiz) {
        this.supShipMentInfoBiz = supShipMentInfoBiz;
    }

    public SupShipMentInfo getSupShipMentInfo() {
        return supShipMentInfo;
    }

    public void setSupShipMentInfo(SupShipMentInfo supShipMentInfo) {
        this.supShipMentInfo = supShipMentInfo;
    }

    public String getJsonString() {
        return jsonString;
    }

    public void setJsonString(String jsonString) {
        this.jsonString = jsonString;
    }

    public List<SupShipMentInfo> getSupShipMentInfos() {
        return supShipMentInfos;
    }

    public void setSupShipMentInfos(List<SupShipMentInfo> supShipMentInfos) {
        this.supShipMentInfos = supShipMentInfos;
    }
}
